//
//  GXShopAddPictureController.m
//  YIChuSeller
//
//  Created by 田小椿 on 2018/12/26.
//  Copyright © 2018年 xiangshengjun. All rights reserved.
//

#import "GXShopAddPictureController.h"
#import "ImagePickerTool.h"
#import "OrderAndUploadPhotoMananger.h"
@interface GXShopAddPictureController ()
@property (weak, nonatomic) IBOutlet UIImageView *pictureImageView;
@property (copy, nonatomic) NSString *imageStr;

@end

@implementation GXShopAddPictureController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"店铺实景图片";
    self.view.backgroundColor = kGlobalbgColor;
}

- (IBAction)uploadPhotoBtn:(id)sender {
    [[ImagePickerTool sharePicker] showImagePicker:self allowEdit:YES complete:^(id param) {
        [OrderAndUploadPhotoMananger uploadPhotoToServerFromImage:param fileName:LiveAction success:^(id responseObject) {
            if (responseObject) {
                self.pictureImageView.image = param;
                self.imageStr = responseObject[@"describa"];
            }
        } fail:^(id responseObject) {
            
        }];
    }];
}


- (IBAction)pressSaveBtn:(id)sender {
    if ([NSString isBlankString:self.imageStr]) {
        [SVProgressHUD showErrorWithStatus:@"实景图未上传成功"];
        return;
    }
    [ShopAuthenticationManager addShopRealPictureWithStoreID:StoreId storeImage:self.imageStr success:^(id responseObject) {
        if (responseObject) {
            if (self.changePictureBlock) {
                self.changePictureBlock(YES);
                [[NSNotificationCenter defaultCenter] postNotificationName:@"addShopPicture" object:nil];
            }
        }
    } fail:^(id responseObject) {
        
    }];
}

@end
